<template>
  <div class="login-bg">
    <div class="login-container">
      <div class="login-box">
        <div class="login-title">dvAdmin管理系统</div>
        <el-form :model="form" class="login-form">
          <el-form-item>
            <el-input v-model="form.username" placeholder="用户名">
              <template #prefix>
                <i class="el-icon-user"></i>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-input v-model="form.password" type="password" placeholder="密码">
              <template #prefix>
                <i class="el-icon-lock"></i>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item class="captcha-row">
            <el-input v-model="form.captcha" placeholder="验证码" style="width: 60%"></el-input>
            <span class="captcha-text">{{ captchaText }}</span>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="form.remember">记住密码</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" class="login-btn" @click="onLogin">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="login-footer">
        Copyright © 2018-2023 anggao-vue-admin.com All Rights Reserved | 蜀ICP备18005193号-3
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      form: {
        username: 'admin',
        password: '',
        captcha: '',
        remember: false,
      },
      captchaText: '1-4=',
    };
  },
  methods: {
    onLogin() {
      // 登录逻辑
      if (this.form.captcha !== '-3') {
        this.$message.error('验证码错误');
        return;
      }
      this.$message.success('登录成功');
    },
  },
};
</script>

<style scoped>
.login-bg {
  width: 100vw;
  height: 100vh;
  background: url('@/assets/img/login-bg.jpeg') no-repeat center center;
  background-size: cover;
  position: relative;
}
.login-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  padding: 36px 40px 24px 40px;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-title {
  font-size: 20px;
  font-weight: bold;
  color: #333;
  margin-bottom: 24px;
  text-align: center;
}
.login-form {
  width: 100%;
}
.captcha-row {
  display: flex;
  align-items: center;
}
.captcha-text {
  margin-left: 12px;
  color: #2d3a4b;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 2px;
  user-select: none;
}
.login-btn {
  width: 100%;
  font-size: 16px;
  height: 40px;
}
.login-footer {
  position: fixed;
  bottom: 16px;
  left: 0;
  width: 100vw;
  text-align: center;
  color: #fff;
  font-size: 13px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.18);
  letter-spacing: 1px;
}
</style>
